/**
 * Created by Administrator on 15-4-10.
 **/
//取id封装函数
function getId(id){
    return document.getElementById(id);
}
//创建遮幕层

function popMask(){
    var box = getId("insertDate");
    var closeAdv = getId("closeAdv");
    var mask = document.createElement("div");
    mask.id="mask";
   // mask.setAttribute("id","mask");
   box.style.display="block";
    closeAdv.style.display = "block";
    var boxHeight = box.offsetHeight;
    var boxWidth = box.offsetWidth;

    var maskCss = "position:fixed;left:0;top:0;z-index:999;width:100%;"
        +"height:100%;filter:alpha(opacity=50);"
        +"-moz-opacity:0.2;opacity:0.2;background:#999";
    var boxCss = "display:block;position:fixed;left:50%;top:50%;z-index:1000;margin:-" + boxHeight / 2 + "px 0 0 -" + (boxWidth-80) / 2 + "px;";

    box.style.cssText = boxCss;
    mask.style.cssText = maskCss;
    document.body.appendChild(mask);
}
//点击隐藏遮幕层
function closeAdv(){
    var inserDate = getId("insertDate");
    var clear = getId("closeAdv");
    var mask = getId("mask");
    inserDate.style.display = "none";
    clear.style.display = "none";
    document.body.removeChild(mask);
}
//点击隐藏遮幕层
function cancel(){
    var inserdate = getId("insertDate");
    var c = getId("closeAdv");
    var mask = getId("mask");
    inserdate.style.display = "none";
    c.style.display = "none";
    document.body.removeChild(mask);
}

//老师名字输入框聚焦检测
  function  teacherNameFocus(){

      var teacherNameId=getId("teacherNameId")
      teacherNameId.className="import_prompt";
      teacherNameId.innerHTML="1.姓名为中文或英文<br/>2.长度为4-20"
    }
//老师名字输入框失去焦点检测
function teacherNameBlur(){
    var teacherName=getId("teacherName");
    var teacherNameId=getId("teacherNameId");
    var reg=/^[\u4e00-\u9fa5]+$/;
    var regE=/^[a-zA-Z]+$/;
    var chinaReg=/[\u4e00-\u9fa5]/g;
    if(!teacherName.value){
        teacherNameId.className="error_prompt";
        teacherNameId.innerHTML="姓名不能为空";
    }else if(!reg.test(teacherName.value) && !regE.test(teacherName.value)){
        teacherNameId.className="error_prompt";
        teacherNameId.innerHTML="1.姓名为中文或英文<br/>2.长度为4-20";
   }else {
        var len = teacherName.value.replace(chinaReg, "ab").length;
        if (len < 4 || len > 20) {
            teacherNameId.className = "error_prompt";
            teacherNameId.innerHTML = "1.姓名为中文或英文<br/>2.长度为4-20";
        }
        else{
                teacherNameId.className = "ok_prompt";
                teacherNameId.innerHTML = "输入正确";
            }
        }
}
//年龄输入框聚焦检测
function ageFocus(){
    var ageId=getId("ageId")
    ageId.className="import_prompt";
    ageId.innerHTML="1.年龄只能是数字</br>2.小于150长度为2-3"
}
//年龄失去焦点检测
function ageBlur(){
    var age=getId("age");
    var ageId=getId("ageId");
    var reg=/^[1-9]+$/;
    if(!age.value){
        ageId.className="error_prompt";
        ageId.innerHTML="姓名不能为空";
    }else if(!reg.test(age.value)){
        ageId.className="error_prompt";
        ageId.innerHTML="1.年龄只能是数字</br>2.小于150长度为2-3";
    }else{
        if(age.value.length < 2 || age.value.length >3 || parseInt(age.value)>150){
            ageId.className="error_prompt";
            ageId.innerHTML="1.年龄只能是数字</br>2.小于150长度为2-3";
        }else{
            ageId.className = "ok_prompt";
            ageId.innerHTML = "输入正确";
        }
    }
}
//班级输入框聚焦检测
function ClassFocus(){
    var ClassId=getId("ClassId");
    ClassId.innerHTML=""
}
//班级输入框失去焦点检测
function ClassBlur(){
    var Class=getId("Class");
    var ClassId=getId("ClassId");
    if(!Class.value){
        ClassId.className="error_prompt";
        ClassId.innerHTML="班级不能为空";
    }else{
        ClassId.className = "ok_prompt";
        ClassId.innerHTML = "输入正确";

    }
}
//科目失去焦点检测
function subjectsBlur(){
    var subjects=getId("subjects");
    var subjectsId=getId("subjectsId");
    if(!subjects.value){
        subjectsId.className="error_prompt";
        subjectsId.innerHTML="班科目不能为空";
    }else{
        subjectsId.className = "ok_prompt";
        subjectsId.innerHTML = "输入正确";

    }
}
//电话号码聚焦检测
function telFocus(){
    var telId = getId("telId");
    telId.className="import_prompt";
    telId.innerHTML="1.以13,15,18开头长度为11</br>2.号码只能是数字"
}
//电话号码失去焦点检测
function telBlur(){
    var tel = getId("tel");
    var telId = getId("telId");
    var reg=/^13||15||18[0-9]{9}$/;
    if(!tel.value){
        telId.className="error_prompt";
        telId.innerHTML="姓名不能为空";
    }else if(!reg.test(tel.value)){
        telId.className="error_prompt";
        telId.innerHTML="1.以13,15,18开头长度为11</br>2.号码只能是数字"
    }else{
        telId.className = "ok_prompt";
        telId.innerHTML = "输入正确";
        }

}
//所属地失去焦点检测
function locationBlur(){
    var location=getId("location");
    var locationId=getId("locationId");
    if(!location.value){
        locationId.className="error_prompt";
        locationId.innerHTML="所属地区不能为空";
    }else{
        locationId.className = "ok_prompt";
        locationId.innerHTML = "输入正确";

    }
}

//学校失去焦点检测
function schoolBlur(){
    var school=getId("school");
    var schoolId=getId("schoolId");
    if(!school.value){
        schoolId.className="error_prompt";
        schoolId.innerHTML="所属学校不能为空";
    }else{
        schoolId.className = "ok_prompt";
        schoolId.innerHTML = "输入正确";

    }
}
//删除信息遮幕层建立
function deleteMask(){
    var box = getId("deleteDate");
    var closeAdiv = getId("closeAdiv");
    var mask = document.createElement("div");
    mask.setAttribute("id","mask");
    box.style.display = "block";
    closeAdiv.style.display = "block";
    var boxHeight = box.offsetHeight;
    var boxWidth = box.offsetWidth;

    var maskCss = "position:fixed;left:0;top:0;z-index:999;width:100%;"
        +"height:100%;filter:alpha(opacity=50);"
        +"-moz-opacity:0.2;opacity:0.2;background:#999";
    var boxCss = "display:block;position:fixed;left:50%;top:50%;z-index:1000;margin:-" + boxHeight / 2 + "px 0 0 -" + (boxWidth-80) / 2 + "px;";

    box.style.cssText = boxCss;
    mask.style.cssText = maskCss;
    document.body.appendChild(mask);
}
//点击隐藏遮幕层
function closeAdiv(){
    var deleteDate = getId("deleteDate");
    var closeAdiv = getId("closeAdiv");
    var mask = getId("mask");
    deleteDate.style.display = "none";
    closeAdiv.style.display = "none";
    document.body.removeChild(mask);
}
//点击隐藏遮幕层
function cancel2(){
    var box = getId("deleteDate");
    var closeAdiv = getId("closeAdiv");
    var mask = getId("mask");
    box.style.display = "none";
    closeAdiv.style.display = "none";
    document.body.removeChild(mask);
}
//下拉菜单隐藏检测
var i = 0;
function selectSchool(dd){
    var u=getId("chengduCity");
    var img=getId("images")
    if(i==0){
        u.style.height="70px";
        dd.childNodes[0].style.width="100%"
        img.setAttribute("src","images/bg4.png")

        i++;
    }else{
        u.style.height="0px";
        img.setAttribute("src","images/bg3.png")
        dd.childNodes[0].style.width="0%"
        i=0;
    }

}
var j=0;
function selectSchool2(dd){
    var u=getId("mianyangCity");
    var img=getId("image")
    if(j==0){
        u.style.height="70px";
        img.setAttribute("src","images/bg4.png")
        dd.childNodes[0].style.width="100%"
        j++;
    }else{
        u.style.height="0px";
        img.setAttribute("src","images/bg3.png")
        dd.childNodes[0].style.width="0%"
        j=0;
    }

}
